<html>
<head><meta charset="utf-8"><title>Fixing sysroot loading · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixing.20sysroot.20loading.html">Fixing sysroot loading</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210671082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixing%20sysroot%20loading/near/210671082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixing.20sysroot.20loading.html#210671082">(Sep 20 2020 at 15:15)</a>:</h4>
<p>Currently sysroot crates have hard-coded dependencies on other sysroot crates, but in reality they can also depend on almost arbitrary <a href="http://crates.io">crates.io</a> crates, and we currently miss those. This can break stuff, for example <code>std::os::unix</code> isn't resolved correctly because the module declaration is produced by <code>cfg_if!</code>. (I'm pretty amazed that the current solution has held up so well!)</p>
<p>I think the correct way to fix this is to start using <code>cargo metadata</code> output, just like we do for user workspaces. The problem with that is that it means we might perform network requests and block for a while when the index is being updated. I think it also means that cargo will create <code>Cargo.lock</code> inside the <code>.rustup</code> toolchain in use, which is not ideal (but required when we only want to pay the startup cost once).</p>
<p>One other thing that came to mind: The rust-src component ships Cargo.lock, so technically no index update like that is necessary. The problem is that it's not located in the right place, and the workspace it was generated for (the whole rust-lang/rust) is not available. We might be able to generate the libstd part of the workspace and reuse the lockfile though, but that means dealing with temp files etc.</p>
<p>Any ideas / Things I'm missing?</p>



<a name="210671160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixing%20sysroot%20loading/near/210671160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixing.20sysroot.20loading.html#210671160">(Sep 20 2020 at 15:17)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/76533">https://github.com/rust-lang/rust/pull/76533</a> would be ideal</p>



<a name="210671227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixing%20sysroot%20loading/near/210671227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixing.20sysroot.20loading.html#210671227">(Sep 20 2020 at 15:19)</a>:</h4>
<p>Ah yeah, that might help. Then we could just ship <code>library/Cargo.toml</code> alongside the lockfile.</p>



<a name="213825401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixing%20sysroot%20loading/near/213825401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixing.20sysroot.20loading.html#213825401">(Oct 19 2020 at 18:21)</a>:</h4>
<p>It turns out that you can totally reuse the global Cargo.lock inside libstd (Cargo will delete all unused entries, but still uses the others).</p>
<p>Only problem is that it has to be copied into the libstd sources, so we'd end up editing the rust-src component.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>